#
#  Copyright 2008 Garth Williams
#
#  This file is part of CommandPost.
#
#  CommandPost is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  CommandPost is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with CommandPost.  If not, see <http://www.gnu.org/licenses/>.
#

  # See how all your routes lay out with "rake routes"

  # The priority is based upon order of creation: first created -> highest priority.

ActionController::Routing::Routes.draw do |map|

  map.resource :session
  map.resources :priorities
  map.resources :milestones
  map.resources :users
  map.resources :roles
  map.resources :reports

  map.resources :report_types do |report_type|
    report_type.resources :stages do |stage|
      stage.resources :paths
    end
  end

  # Sample of regular route:
  #   map.connect 'products/:id', :controller => 'catalog', :action => 'view'
  # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:
  #   map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
  # This route can be invoked with purchase_url(:id => product.id)

  # Sample resource route (maps HTTP verbs to controller actions automatically):
  #   map.resources :products

  # Sample resource route with options:
  #   map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }

  # Sample resource route with sub-resources:
  #   map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller

  # Sample resource route within a namespace:
  #   map.namespace :admin do |admin|
  #     # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
  #     admin.resources :products
  #   end

  map.root :controller => "home_screen"
  
  map.connect 'report_types/:id/first_stage/:stage_id', :controller => 'report_types', :action => 'set_first', :conditions => { :method => :post }
  
  map.connect 'responsibilities/:action/:user_id/:role_id', :controller => 'responsibilities', :conditions => { :method => :post }
  map.connect 'report_type_permissions/:report_type_id/:role_id', :controller => 'report_type_permissions', :action => 'update', :conditions => { :method => :post }
  map.connect 'path_assignments/:path_id/:role_id', :controller => 'path_assignments', :action => 'update', :conditions => { :method => :post }
  map.connect 'stage_assignments/:stage_id/:role_id', :controller => 'stage_assignments', :action => 'update', :conditions => { :method => :post }

  map.connect 'pages', :controller => 'pages', :action => 'index', :conditions => { :method => :get }
  map.connect 'pages/:name', :controller => 'pages', :action => 'show', :conditions => { :method => :get }
  map.connect 'pages/:name/edit', :controller => 'pages', :action => 'edit', :conditions => { :method => :get }
  map.connect 'pages/:name', :controller => 'pages', :action => 'update'

  # Install the default routes as the lowest priority.
  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'
end
